Repository navigation
security: add CSP and security headers to console-ui (SEC-014) - #213
Conversation
Add Content-Security-Policy, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Strict-Transport-Security, and Permissions-Policy headers to all console-ui routes via next.config.ts headers(). CSP directives: - default-src 'self' - script-src: self + Google Tag Manager + Stripe.js - connect-src: self + coordinator API + Privy auth + GA + Stripe API - frame-src: Privy auth iframes + Stripe Checkout iframes - frame-ancestors 'none' (clickjacking prevention) - img-src: self + data/blob + https (for external avatars/icons) Other headers: - X-Frame-Options: DENY (legacy clickjacking prevention) - X-Content-Type-Options: nosniff (MIME sniffing prevention) - Referrer-Policy: strict-origin-when-cross-origin - HSTS: max-age=63072000 with includeSubDomains and preload - Permissions-Policy: deny camera, microphone, geolocation Closes SEC-014 (T-019).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Benchmark ResultsRunner: 1-provider-streaming1 providers, 1 users, 30 requests, concurrency=5, streaming=true
Latency Decomposition
Assertion Report: PASS
1-provider-non-streaming1 providers, 1 users, 20 requests, concurrency=5, streaming=false
Latency Decomposition
Assertion Report: PASS
7-provider-multi-model7 providers, 5 users, 50 requests, concurrency=10, streaming=true
Latency Decomposition
Assertion Report: PASS
3-provider-high-concurrency3 providers, 10 users, 60 requests, concurrency=20, streaming=true
Latency Decomposition
Assertion Report: PASS
1-provider-queue-saturation1 providers, 10 users, 40 requests, concurrency=15, streaming=true
Latency Decomposition
Assertion Report: PASS
3-provider-20-users3 providers, 20 users, 60 requests, concurrency=10, streaming=true
Latency Decomposition
Assertion Report: PASS
1-provider-scaling1 providers, 5 users, 30 requests, concurrency=10, streaming=true
Latency Decomposition
Assertion Report: PASS
3-provider-scaling3 providers, 5 users, 30 requests, concurrency=10, streaming=true
Latency Decomposition
Assertion Report: PASS
5-provider-scaling5 providers, 5 users, 30 requests, concurrency=10, streaming=true
Latency Decomposition
Assertion Report: PASS
3-provider-heavy-100conc-10kb3 providers, 20 users, 100 requests, concurrency=100, streaming=true
Latency Decomposition
Assertion Report: FAIL
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 562b16a71c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "style-src 'self' 'unsafe-inline'", | ||
| "img-src 'self' data: blob: https:", | ||
| "font-src 'self' data:", | ||
| "connect-src 'self' https://api.darkbloom.dev https://*.privy.io wss://*.privy.io https://www.google-analytics.com https://api.stripe.com", |
There was a problem hiding this comment.
Allow non-default coordinator origins in connect-src
The new CSP hardcodes connect-src to https://api.darkbloom.dev, but the UI intentionally supports alternate coordinator endpoints (for example via localStorage.getItem("darkbloom_coordinator_url") and NEXT_PUBLIC_COORDINATOR_URL in provider pages) and then issues browser-side fetch calls to that dynamic origin. With this header, any non-default deployment/dev environment will have those requests blocked by CSP, breaking flows like provider dashboard and earnings outside api.darkbloom.dev.
Useful? React with 👍 / 👎.
Summary
Adds six security headers to all console-ui routes via
next.config.tsheaders(). Closes the open finding SEC-014 (threat T-019: missing security headers increase XSS blast radius).Headers Added
Content-Security-PolicyX-Frame-OptionsDENYX-Content-Type-OptionsnosniffReferrer-Policystrict-origin-when-cross-originStrict-Transport-Securitymax-age=63072000; includeSubDomains; preloadPermissions-Policycamera=(), microphone=(), geolocation=()CSP Directives
default-src'self'script-src'self' 'unsafe-inline' 'unsafe-eval' googletagmanager stripe.jsstyle-src'self' 'unsafe-inline'img-src'self' data: blob: https:font-src'self' data:connect-src'self' api.darkbloom.dev *.privy.io google-analytics stripeframe-srcauth.privy.io js.stripe.comframe-ancestors'none'base-uri'self'form-action'self'Verification
npm run buildpasses/(.*)source patternNotes
unsafe-inlineandunsafe-evalin script-src are required by the Privy SDK and Next.js runtime. A future improvement would be moving to nonce-based CSP.connect-srcandframe-src-- if new external services are added, their origins must be allowlisted here.Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.